'\" t
.\"<!-- Copyright 1998 - 2010 Double Precision, Inc.  See COPYING for -->
.\"<!-- distribution information. -->
.\"     Title: reformime
.\"    Author: Sam Varshavchik
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\"      Date: 06/20/2015
.\"    Manual: Double Precision, Inc.
.\"    Source: Courier Mail Server
.\"  Language: English
.\"
.TH "REFORMIME" "1" "06/20/2015" "Courier Mail Server" "Double Precision, Inc\&."
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
reformime \- MIME E\-mail reformatting tool
.SH "SYNOPSIS"
.HP \w'\fBreformime\fR\ 'u
\fBreformime\fR [\fIoptions\fR...]
.SH "DESCRIPTION"
.PP
\fBreformime\fR
is a utility for reformatting MIME messages\&.
.PP
Generally,
\fBreformime\fR
expects to see an
\m[blue]\fBRFC 2045\fR\m[]\&\s-2\u[1]\d\s+2
compliant message on standard input, except in few cases such as the
\fB\-m\fR
option\&.
.PP
If no options are given,
\fBreformime\fR
prints the MIME structure of the message\&. The output consists of so\-called "MIME reference tags", one per line\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
1
1\&.1
1\&.2
.fi
.if n \{\
.RE
.\}
.PP
This shows that the message contains two different MIME sections\&. The first line of the MIME structure output will always contain "1", which refers to the entire message\&. In this case it happens to be a
multipart/mixed
message\&. "1\&.1" refers to the first section of the multipart message, which happens to be a
text/plain
section\&. "1\&.2" refers to the second section of the message, which happens to be an
application/octet\-stream
section\&.
.PP
If the message is not a MIME message, or it does not contain any attachments,
\fBreformime\fR
prints only "1", that refers to the entire message itself:
.sp
.if n \{\
.RS 4
.\}
.nf
1
.fi
.if n \{\
.RE
.\}
.PP
Here\*(Aqs the output from
\fBreformime\fR
when the first part of the message was itself a
multipart/alternative
section:
.sp
.if n \{\
.RS 4
.\}
.nf
1
1\&.1
1\&.1\&.1
1\&.1\&.2
1\&.2
.fi
.if n \{\
.RE
.\}
.PP
Arbitrarily complex MIME constructs are possible\&.
.SH "OPTIONS"
.PP
\-d
.RS 4
Parse a delivery status notification MIME message (\m[blue]\fBRFC 1894\fR\m[]\&\s-2\u[2]\d\s+2)\&.
\fBreformime\fR
expects to see on standard input a MIME message that consists of a delivery status notification, as defined by RFC 1894\&.
\fBreformime\fR
reads the message and prints on standard output a list of addresses and their corresponding delivery status, as specified in the delivery status notification\&. Each line printed by
\fBreformime\fR
consists of a delivery status, a space, and the address\&.
\fBreformime\fR
then terminates with a 0 exit status\&.
\fBreformime\fR
produces no output and terminates with an exit status of 1 if the standard input does not contain a delivery status notification\&.
.RE
.PP
\-D
.RS 4
Like the
\fB\-d\fR
except that
\fBreformime\fR
lists the address found in the
Original\-Recipient:
header, if it exists\&.
.RE
.PP
\-e
.RS 4
Extract the contents of the indicated MIME section, and display it on standard output\&. The
\fB\-s\fR
option is required when
\fB\-e\fR
is specified\&. If the specified section or sections use either the
base64
or
quoted\-printable
encoding method,
\fBreformime\fR
automatically decodes it\&. In this case you\*(Aqre better off redirecting the standard output into a file\&.
.RE
.PP
\-i
.RS 4
Display MIME information for each section\&.
\fBreformime\fR
displays the contents of the
Content\-Type:
header, any encoding used, and the character set\&.
\fBreformime\fR
also displays the byte offset in the message where each section starts and ends (and where the actual contents of the section start, after skipping all the headers)\&.
.RE
.PP
\-m
.RS 4
Create a
multipart/digest
MIME message digest\&.
.RE
.PP
\-r
.RS 4
Rewrite message, adding or standardizing
\m[blue]\fBRFC 2045\fR\m[]\&\s-2\u[1]\d\s+2
MIME headers\&.
.RE
.PP
\-r7
.RS 4
Like
\fB\-r\fR
but also convert
8bit\-encoded MIME sections to
quoted\-printable\&.
.RE
.PP
\-r8
.RS 4
Like
\fB\-r\fR
but also convert
quoted\-printable\-encoded MIME sections to
8bit\&.
.RE
.PP
\-s \fIsection\fR
.RS 4
Display MIME information for this section only\&.
\fIsection\fR
is a MIME specification tag\&. The
\fB\-s\fR
option is required if
\fB\-e\fR
is also specified, and is optional with
\fB\-i\fR\&.
.sp
Multiple sections may be specified by separating them with commas\&.
\fBreformime\fR
processes each section using the other options that were specified\&.
.RE
.PP
\-x
.RS 4
Extract the contents of the indicated MIME section to a file\&.
.RE
.PP
\-X
.RS 4
Pipe the contents of the indicated MIME section to a program\&.
.RE
.SS "Extracting RFC 2045 MIME section(s) to file(s)"
.PP
The
\fB\-x\fR
and
\fB\-X\fR
options extract a specific MIME section to a file or to a pipe to an external program\&. Use the
\fB\-s\fR
option to identify the MIME section to extract\&. If the
\fB\-s\fR
option is not specified, every MIME section in the message is extracted, one at a time\&. If
\fB\-s\fR
lists multiple sections, each section gets extracted separately\&.
quoted\-printable
and
base64
encoding are automatically decoded\&.
.PP
\-x
.RS 4
Interactive extraction\&.
\fBreformime\fR
prints the MIME content type of each section\&. Answer with \*(Aqy\*(Aq or \*(AqY\*(Aq to extract the MIME section\&. Specify the filename at the next prompt\&.
\fBreformime\fR
prompts with a default filename\&.
\fBreformime\fR
tries to choose the default filename based on the MIME headers, if possible\&. If not, the default filename will be
attachment1\&.dat
(if the \-s option is not specified, the next filename will be
attachment2\&.dat, and so on)\&.
.RE
.PP
\-x\fIPREFIX\fR
.RS 4
Automatic extraction\&.
\fBreformime\fR
automatically extracts one or more MIME sections, and saves them to a file\&. The filename is formed by taking
\fIPREFIX\fR, and appending the default filename to it\&. Note that there\*(Aqs no space between "\-x" and "PREFIX"\&. For example:
.sp
.if n \{\
.RS 4
.\}
.nf
reformime \-xfiles\-
.fi
.if n \{\
.RE
.\}
This command saves MIME sections as
files\-attachment1\&.dat, then
files\-attachment2\&.dat, etc\&.
\fBreformime\fR
tries to append the filename specified in the MIME headers for each section, where possible\&.
\fBreformime\fR
replaces all suspect characters with the underscore character\&.
.RE
.PP
\-X prog arg1 arg2 \&.\&.\&.
.RS 4
The
\fB\-X\fR
option must be the last option to
\fBreformime\fR\&.
\fBreformime\fR
runs an external program
\fBprog\fR, and pipes the contents of the MIME section to the program\&.
\fBreformime\fR
sets the environment variable
\fBCONTENT_TYPE\fR
to the MIME content type\&. The environment variable
\fBFILENAME\fR
gets set to the default filename of
\fBreformime\fR\*(Aqs liking\&. If the
\fB\-s\fR
option is not specified, the program runs once for every MIME section in the message\&. The external program,
\fBprog\fR
must terminate with a zero exit status in order for
\fBreformime\fR
to proceed to the next MIME section in the message (or the next section specified by
\fB\-s\fR)\&. In any case, if
\fBprog\fR
terminates with a non\-zero exit status,
\fBreformime\fR
terminates with the exit status of 20 plus
\fBprog\fR\*(Aqs exit status\&.
.RE
.if n \{\
.sp
.\}
.RS 4
.it 1 an-trap
.nr an-no-space-flag 1
.nr an-break-flag 1
.br
.ps +1
\fBNote\fR
.ps -1
.br
.PP
\fBreformime\fR
extracts every MIME section in the message unless the
\fB\-s\fR
option is specified\&. This includes even the
text/plain
MIME content that usually precedes a binary attachment\&.
.sp .5v
.RE
.SS "Adding RFC 2045 MIME headers"
.PP
The
\fB\-r\fR
option performs the following actions:
.PP
If there is no
Mime\-Version:,
Content\-Type:, or
Content\-Transfer\-Encoding:
header,
\fBreformime\fR
adds one\&.
.PP
If the
Content\-Transfer\-Encoding:
header contains
8bit
or
raw, but only seven\-bit data is found,
\fBreformime\fR
changes the
Content\-Transfer\-Encoding
header to
7bit\&.
.PP
\fB\-r7\fR
does the same thing, but also converts
8bit\-encoded content that contains eight\-bit characters to
quoted\-printable
encoding\&.
.PP
\fB\-r8\fR
does the same thing, but also converts
quoted\-printable\-encoded content to
8bit, except in some situations\&.
.SS "Creating multipart/digest MIME digests"
.PP
The
\fB\-m\fR
option creates a MIME digest\&.
\fBreformime\fR
reads a list of filenames on standard input\&. Each line read from standard input contains the name of a file that is presumed to contain an RFC 2822\-formatted message\&.
\fBreformime\fR
splices all files into a
\fBmultipart/digest\fR
MIME section, and writes it to standard output\&.
.SS "Translating MIME headers"
.PP
The following options do not read a message from standard input\&. These options process MIME headers via the command line, and are designed to be conveniently used by mail\-handling scripts\&.
.PP
\-h "\fIheader\fR"
.RS 4
Decode a MIME\-encoded "\fIheader\fR" and print the decoded 8\-bit content on standard output\&. The decoding gets carried out as if the contents occurred in the
\(lqSubject\(rq
header\&. Example:
.sp
.if n \{\
.RS 4
.\}
.nf
$ reformime \-h \*(Aq=?iso\-8859\-1?Q?H=F3la!?=\*(Aq
Hóla!
.fi
.if n \{\
.RE
.\}
.RE
.PP
\-H "\fIheader\fR"
.RS 4
Like
\fB\-h\fR
except that
\fIheader\fR
is parsed as a list of email addresses, like
\(lqFrom\(rq
or
\(lqTo\(rq\&.
.RE
.PP
\-o "\fItext\fR"
.RS 4
MIME\-encode "\fItext\fR", and print the results on standard output\&.
.RE
.PP
\-O "\fItext\fR"
.RS 4
Like the
\fB\-o option\fR, except that
\fItext\fR
is a structured header with RFC 2822 addresses\&.
.RE
.PP
\-c "\fIcharset\fR"
.RS 4
Use
\fIcharset\fR
as the character set setting, by the
\fB\-h\fR,
\fB\-H\fR,
\fB\-o\fR
and
\fB\-O\fR
options\&.
.RE
.PP
\-u
.RS 4
This
\(lqundocumented\(rq
option reads a MIME message on standard input, and converts its contents to an UTF\-8\-encoded character stream, which is written to standard output\&.
.sp
The standard output receives a concatenated amalgam of the headers and
\(lqtext\(rq
MIME object data\&. It is meant to be used as part of a generic search function\&. This option decodes various kinds of header MIME encoding, the
quoted\-printable
and
base64
transfer encodings of
\(lqtext\(rq
MIME objects\&.
.RE
.SH "SEE ALSO"
.PP
\m[blue]\fB\fBreformail\fR(1)\fR\m[]\&\s-2\u[3]\d\s+2,
\fBsendmail\fR(8),
\m[blue]\fB\fBmailbot\fR(1)\fR\m[]\&\s-2\u[4]\d\s+2,
\m[blue]\fB\fBmaildrop\fR(1)\fR\m[]\&\s-2\u[5]\d\s+2,
\m[blue]\fB\fBmaildropfilter\fR(5)\fR\m[]\&\s-2\u[6]\d\s+2,
\fBegrep\fR(1),
\fBgrep\fR(1),
\fBsendmail\fR(8)\&.
.SH "AUTHOR"
.PP
\fBSam Varshavchik\fR
.RS 4
Author
.RE
.SH "NOTES"
.IP " 1." 4
RFC 2045
.RS 4
\%http://www.rfc-editor.org/rfc/rfc2045.txt
.RE
.IP " 2." 4
RFC 1894
.RS 4
\%http://www.rfc-editor.org/rfc/rfc1894.txt
.RE
.IP " 3." 4
\fBreformail\fR(1)
.RS 4
\%[set $man.base.url.for.relative.links]/reformail.html
.RE
.IP " 4." 4
\fBmailbot\fR(1)
.RS 4
\%[set $man.base.url.for.relative.links]/mailbot.html
.RE
.IP " 5." 4
\fBmaildrop\fR(1)
.RS 4
\%[set $man.base.url.for.relative.links]/maildrop.html
.RE
.IP " 6." 4
\fBmaildropfilter\fR(5)
.RS 4
\%[set $man.base.url.for.relative.links]/maildropfilter.html
.RE
